package cn.hzu580.util;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import org.springframework.util.FileCopyUtils;

public class FileUtil {

	public static void saveFile(File file, String path, String fileName){
		ServletContext context = ServletActionContext.getServletContext();
	    String realPath = context.getRealPath(path);
	    try {
			FileCopyUtils.copy(file, new File(realPath+"/"+fileName));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
